using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Sandia.MVCFramework.ViewManager
{
    /// <summary>
    /// A mainLayout node for defining splits in the UI. This split is defined by
    /// providing left and right children which should reside on their
    /// respective sides in the split.
    /// </summary>
    public class SplitLayoutNode : ILayoutNode
    {
        /// <summary>
        /// The parent of this node.
        /// </summary>
        private ILayoutNode parent;

        /// <summary>
        /// The left child of this node.
        /// </summary>
        private ILayoutNode leftChild;

        /// <summary>
        /// The right child of this node.
        /// </summary>
        private ILayoutNode rightChild;

        /// <summary>
        /// The orientation of the split (i.e. horizontal/vertical).
        /// </summary>
        private Orientation orientation;

        /// <summary>
        /// The distance from the top or the left of the split that the splitter
        /// should be at (measured in pixels).
        /// </summary>
        private int splitterDistance;

        /// <summary>
        /// Constructor for SplitLayoutNode
        /// </summary>
        /// <param name="leftChild">
        /// The left child of this node.
        /// </param>
        /// <param name="rightChild">
        /// The right child of this node.
        /// </param>
        /// <param name="orientation">
        /// The orientation of the split (i.e. horizontal/vertical).
        /// </param>
        /// <param name="splitterDistance">
        /// The distance from the top or the left of the split that the splitter
        /// should be at (measured in pixels).
        /// </param>
        public SplitLayoutNode(
            ILayoutNode leftChild,
            ILayoutNode rightChild,
            Orientation orientation,
            int splitterDistance)
        {
            this.leftChild = leftChild;
            this.leftChild.Parent = this;
            this.rightChild = rightChild;
            this.rightChild.Parent = this;
            this.orientation = orientation;
            this.splitterDistance = splitterDistance;
        }

        #region ILayoutNode Members

        /// <summary>
        /// The parent of this node.
        /// </summary>
        public ILayoutNode Parent
        {
            get { return this.parent; }
            set { this.parent = value; }
        }

        #endregion

        /// <summary>
        /// The left child of this node.
        /// </summary>
        public ILayoutNode LeftChild
        {
            get { return this.leftChild; }
            set { this.leftChild = value; }
        }

        /// <summary>
        /// The right child of this node.
        /// </summary>
        public ILayoutNode RightChild
        {
            get { return this.rightChild; }
            set { this.rightChild = value; }
        }

        /// <summary>
        /// The orientation of the split (i.e. horizontal/vertical).
        /// </summary>
        public Orientation Orientation
        {
            get { return this.orientation; }
            set { this.orientation = value; }
        }

        /// <summary>
        /// The distance from the left or top of the split.
        /// </summary>
        public int SplitterDistance
        {
            get { return this.splitterDistance; }
            set { this.splitterDistance = value; }
        }
    }
}
